import {
  submit,
  submitUpdateState,
  removeByIds as delData,
  updateState as voidData,
} from "@/api/legal-case/acceptance";
export default {
  dicts: [
    "document_type",
    "sys_user_sex",
    "nation",
    "marital_status",
    "educational_level",
    "physical_condition",
    "occupation",
    "case_type",
    "transaction_class",
    "legal_status",
    "matter_status",
    "help_status",
    "case_source",
    "case_status",
    "type_of_case",
    "lawsuit",
    "step_state",
    "specify_the_reasion",
    "stage_of_proceedings",
    "legal_status_penal",
    "the_case_involves",
    "legal_status_executive",
    "user_type",
    "expertise",
    "notice_type",
    "data_source",
    "consult_status",
    "process_mode",
    "law_consult_militarily",
    "case_terminate_state",
    "type_of_militarily",
  ],
  data() {
    return {
      loading: false,
      total: 0,
      queryParam: {
        pageNum: 1,
        pageSize: 10,
      },
      METHODS_NAME: "getList",
      currentComponent: "",
      currentComponentLook: "",
      comArr: [
        "",
        "wang-examine",
        "wang-application-info",
        "wang-notification-info",
        "wang-admission-info",
        "wang-administrative-info",
        "wang-notary-info",
        "wang-agent-info",
        "wang-judicial-info",
      ],
      wangShow: [],
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 0) {
        return "warning-row";
      } else if (rowIndex % 4 == 0) {
        return "success-row";
      }
      return "";
    },
    Slotfocus(val, key) {
      this.$refs[key].handleOpen(val);
      this.$refs.inputRef.blur();
    },
    getList() {
      console.error("定义数据方法getList");
    },
    indexMethod(index) {
      return (
        index + 1 + (this.queryParam.pageNum - 1) * this.queryParam.pageSize
      );
    },
    onShowSizeChange(pageSize) {
      this.queryParam.pageNum = 1;
      this.queryParam.pageSize = pageSize;
      this[this.METHODS_NAME]();
    },
    changeSize(current, pageSize) {
      this.queryParam.pageNum = current;
      this.queryParam.pageSize = pageSize;
      this[this.METHODS_NAME]();
    },
    // 查询
    handleQuery(val) {
      this.queryParam.pageNum = 1;
      this.queryParam = Object.assign({}, this.queryParam, val);
      this[this.METHODS_NAME]();
    },
    submitForm() {
      this.$refs.CreateForm.submitForm();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 案件转办
    caseTurnClick(val, title) {
      this.row = val;
      this.$refs.wangExamineEdit.handleOpen(val, title);
    },
    voidData(data) {
      this.$confirm("您确认作废吗？")
        .then(() => {
          let obj = {
            caseIdList: [data.caseId],
            step: -5,
            caseStatus: 7,
          };
          voidData(obj).then((res) => {
            this.$notify({
              title: "成功",
              message: "操作成功",
              type: "success",
              position: "bottom-right",
            });
            this.getList();
          });
        })
        .catch(() => {});
    },
    delData(ids) {
      this.$confirm("您确认删除吗？")
        .then(() => {
          delData({ caseIdList: [ids] }).then((res) => {
            this.$notify({
              title: "成功",
              message: "操作成功",
              type: "success",
              position: "bottom-right",
            });
            this.getList();
          });
        })
        .catch(() => {});
    },
    delDatas() {
      if (this.multipleSelection.length) {
        this.$confirm(`您确认删除这${this.multipleSelection.length}条数据吗？`)
          .then(() => {
            delData({
              caseIdList: this.multipleSelection.map((item) => item.caseId),
            }).then((res) => {
              this.successMessage();
              this.multipleSelection = [];
              this.getList();
            });
          })
          .catch(() => {});
      } else {
        this.errorMessage();
      }
    },
    // 案件转办
    caseTurnClick(val, title) {
      this.row = val;
      this.$refs.wangExamineEdit.handleOpen(val, title);
    },
    // 材料下载
    materialClick(row) {
      this.tableId = row;
      this.materialShow = true;
    },
    handleClicks(val, title) {
      if (val.step == "1") {
        this.wangShow = [true, true, true, true, true, false, false, false];
      } else {
        this.wangShow = [true, true, true, true, true, true, false, false];
      }
      this.$refs.wangExamine.handleOpen(val, title);
    },
    handleClick(val, title) {
      this.$refs.CreateForm.handleOpen(val, title);
    },
    handleClose() {
      this.$confirm("确认关闭？")
        .then(() => {
          this.$refs.wangExamineEdit.dialogVisible = false;
        })
        .catch(() => {});
    },
    closeFun() {
      this.$refs.wangExamineEdit.dialogVisible = false;
    },
    submitForm() {
      this.$refs.CreateForm.submitForm();
    },
    submitFormRollOut() {
      this.$refs.RollOut.submitForm();
    },
    successMessage() {
      this.$notify({
        title: "成功",
        message: "操作成功",
        type: "success",
        position: "bottom-right",
      });
    },
    errorMessage() {
      this.$notify({
        title: "失败",
        message: "操作失败您还未选择案件",
        type: "error",
        position: "bottom-right",
      });
    },
    batch() {
      if (this.multipleSelection.length) {
        this.$confirm(
          `您确定审查通过这${this.multipleSelection.length}条数据吗？`
        )
          .then(() => {
            if (this.$store.state.user.user?.manage == "2") {
              submitUpdateState({
                caseIdList: this.multipleSelection.map((item) => item.caseId),
                step: "7",
                caseStatus: "2",
              }).then(() => {
                this.successMessage();
                this.multipleSelection = [];
                this.getList();
              });
            } else {
              submit({
                caseIdList: this.multipleSelection.map((item) => item.caseId),
              }).then(() => {
                this.successMessage();
                this.multipleSelection = [];
                this.getList();
              });
            }
          })
          .catch(() => {});
      } else {
        this.errorMessage();
      }
    },
    // 查询
    onSearch(val) {
      this.getList(val);
    },
  },
};
